package liming.ai.code.v4.data;

import java.io.File;

public class BaseConfig {
    public static final String PROJECT_PATH="./test/";
    public static final String JAVAS_PATH = "./src/main/java/";
    public static final String CLASSES_PATH = "./target/classes/";
    public static final String MDS_FILE_PATH = "./target/generated-docs/";

    private static final BaseConfig baseConfig = new BaseConfig();

    private final String projectPath;
    private final String javasPath;
    private final String classesPath;
    private final String mdsFilePath;
    BaseConfig(){
        projectPath=new File(PROJECT_PATH).getAbsolutePath();
        this.javasPath=getPath(JAVAS_PATH);
        this.classesPath=getPath(CLASSES_PATH);
        this.mdsFilePath=getPath(MDS_FILE_PATH);
    }
    private String getPath(String path){
        File file = new File(projectPath, path);
        if(!file.exists())
            file.mkdirs();
        return file.getAbsolutePath();
    }

    @Override
    public String toString() {
        return "BaseConfig{" +
                "projectPath='" + projectPath + '\'' +
                ", javasPath='" + javasPath + '\'' +
                ", classesPath='" + classesPath + '\'' +
                ", mdsFilePath='" + mdsFilePath + '\'' +
                '}';
    }

    public static String getProjectPath(){
        return baseConfig.projectPath;
    }
    public static String getJavasPath() {
        return baseConfig.javasPath;
    }
    public static String getMdsFilePath() {
        return baseConfig.mdsFilePath;
    }
    public static String getClassesPath() {
        return baseConfig.classesPath;
    }

    public static String getBaseInfo(){
        StringBuilder sb = new StringBuilder();
        sb.append("当前项目根路径为:").append(PROJECT_PATH).append("\n")
                .append("Java源文件根路径为:").append(JAVAS_PATH).append("\n")
                .append("class编译文件根路径为:").append(CLASSES_PATH).append("\n")
                .append("md介绍文件根路径为:").append(MDS_FILE_PATH).append("\n");
        return sb.append(baseConfig).append("\n").toString();
    }
}
